# The path to the NDK, requires crystax version r-4 for now, due to support
# for the standard library

# load environment from local make file
LOCAL_ENV_MK=local.env.mk
include $(LOCAL_ENV_MK)

ifndef ARM_TARGETS
ARM_TARGETS="armeabi armeabi-v7a"
endif
ANDROID_NDK_BASE = $(ANDROID_NDK_ROOT)

$(info OPENCV_CONFIG = $(OPENCV_CONFIG))

ifndef PROJECT_PATH
$(info PROJECT_PATH defaulting to this directory)
PROJECT_PATH=.
endif


# The name of the native library
LIBNAME = libvision-spice.so


# Find all the C++ sources in the native folder
SOURCES = $(wildcard jni/*.cpp)
HEADERS = $(wildcard jni/*.h)

ANDROID_MKS = $(wildcard jni/*.mk)

BUILD_DEFS=OPENCV_CONFIG=$(OPENCV_CONFIG) \
	PROJECT_PATH=$(PROJECT_PATH) \
	V=$(V) \
	$(NDK_FLAGS) \
	ARM_TARGETS=$(ARM_TARGETS)

# The real native library stripped of symbols
LIB		= libs/armeabi-v7a/$(LIBNAME) libs/armeabi/$(LIBNAME)

all:	$(LIB)

#calls the ndk-build script, passing it OPENCV_ROOT and OPENCV_LIBS_DIR
$(LIB): $(SOURCES) $(HEADERS) $(ANDROID_MKS)
	$(ANDROID_NDK_BASE)/ndk-build $(BUILD_DEFS)

#clean targets
.PHONY: clean cleanall

clean:
	$(ANDROID_NDK_BASE)/ndk-build clean $(BUILD_DEFS)

